
#include <BTextEdit>
#include <BStyle>

#include "InitFormat.h"

InitFormat::InitFormat(const BString& name) : BTextFormat(name)
{
	_textEdit = 0;

	_dockLayout = new BDockLayout();
	_dockLayout->setPart(Part_Center);
	_dockLayout->setSplitable(true);
	_dockLayout->setSpacing(5);
	_treeWidget = new BTreeWidget();
	_treeWidget->setWidthPolicy(Policy_Preferred | Policy_Expanding);
	_dockLayout->addWidget(_treeWidget, Align_RightTop);
	_dockLayout->setStretch(_treeWidget, BSizeStretch(0.1f, 0.5f));

	connect(this, Signal_AssetChanged, &InitFormat::slotAssetChanged);
}
InitFormat::~InitFormat()
{

}

void InitFormat::styled(const BStyle* style)
{

}
void InitFormat::changed(const BString& text)
{

}


void InitFormat::slotAssetChanged(BObject* object, const BValue& value)
{
	BTextEdit* textEdit = value;
	if (_textEdit != textEdit)
	{

		_dirty = true;
		_treeWidget->clearItems();
		textEdit->addLayout(_dockLayout);
	}
	else
	{
		_dirty = false;
		_treeWidget->clearItems();
		textEdit->removeLayout(_dockLayout);
	}
}

